class Solution:
    def minSubArrayLen(self, s: int, nums: list) -> int:
        i, j, mid_sum, res = 0, 0, 0, len(nums) + 1
        try:
            while True:
                while mid_sum < s:
                    mid_sum += nums[j]
                    j += 1
                while mid_sum >= s:
                    mid_sum -= nums[i]
                    i += 1
                res = min(res, j - i + 1)
        except:
            if res == len(nums) + 1:
                return 0
            return res


a = Solution()
print(a.minSubArrayLen(s=7, nums=[2, 3, 1, 2, 4, 3]))
